import 'package:flutter/material.dart';
import 'package:flutter_jd/pages/search/view.dart';
import 'package:flutter_jd/ui/widgets/kit.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/route_manager.dart';

// 搜索栏（无法获取焦点版本）
class SearchBar extends StatelessWidget {
  final double height; // 高度
  final String placeholderText; // 默认文字
  final Color? background; // 默认文字

  SearchBar({
    this.placeholderText: '',
    this.height: 32,
    this.background,
  });

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: Container(
        height: height.h,
        child: Container(
          height: 32.h,
          decoration: BoxDecoration(
            color: background,
            borderRadius: BorderRadius.circular(20.r),
          ),
          child: Container(
            padding: EdgeInsets.only(left: 12.w, right: 12.w),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Kit.iconFont(0xe692, Color(0xFF999999), 15.sp),
                Expanded(
                  child: GestureDetector(
                    onTap: () {
                      Get.to(
                        () => SearchPage(),
                        transition: Transition.downToUp,
                      );
                    },
                    child: Container(
                      margin: EdgeInsets.only(left: 5.w),
                      child: Text(
                        placeholderText,
                        style: TextStyle(
                          color: Color(0xFF999999),
                          fontSize: 14.sp,
                        ),
                      ),
                    ),
                  ),
                ),
                Kit.iconFont(0xe614, Color(0xFF999999), 15.sp),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
